<!DOCTYPE HTML>
<html>
<head>
   <meta charset="UTF-8" />
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
    <title>title</title>
    <script type="text/javascript" src="../../script/s94.js#debug"></script>
    <script type="text/javascript" src="../../script/s94.app.js"></script>
    <!--公共部分-->
    <script type="text/javascript" src="../../script/common.js"></script>
    <link href="../../css/common.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
	.body{font-size: 0.28rem;}
	.body .button{margin: 0.1rem;}
	.title{width: 100%;margin: 0.6rem 0 0.2rem 0;text-align: center;font-size: 0.36rem;font-weight: bold;}
</style>
<body>
	<header class="public">
		<a app href="back" target="_blank"><i ico class="ico-fx-l"></i></a>
		<div class="set-xy full">模块测试</div>
	</header>
	<div class="body">
		<form action="">
			<label class="row"><span>模块：</span><input type="text" name="msg" value="Hello ,welcome to Beijing!"></label>
			<label class="row"><span>速度：</span><input type="number" name="speed" value="0.8"></label>
		</form>
		<br>
		<div class="button" act="test">测试</div>

		<br>
        <div class="button" act="init">初始化</div>
        <div class="button" act="speak">语音合成</div>
	</div>
</body>
<script type="text/javascript">
//每个方法传递的参数
var params = {
	init : {},
    speak : function(){
		var res={};
		$('form').serializeArray().forEach(function(row){
			res[row.name] = row.value;
		})
		return res;
	}
}
$.app(function(){ //APP加载完成后执行回调函数，等效于apicloud的apiready方法
	var md = $.app("http");//等效于api.require(module);
	//所有按钮统一绑定事件
	$('.button[act]').on("click",function(){
		var act = $(this).attr("act"); //获取需要执行的方法名称
		var param = params[act]; //获取执行的方法需要传递的参数
		switch (typeof(param)) {
			case 'underfind': param = {};break;
			case 'function': param = param();break;
		}
		md[act](param, function(res){
			tips(res.msg);
			$.log(res, act);
			if(!res.status) return;
			switch (act) {
				case 'start':{
					document.querySelector('.filepath>span').innerText = res.path;
					displayNitce.md2 = md2;
					md2.create({
						title: "点击停止录屏",
						content: "00:00",
						ongoing: true
					},function(res2){
						if(res2.id){
							displayNitce.id = res2.id;
							displayNitce();
						}
						if(res2.msg=="event" && res2.eventName=="click"){
							md.stop();
							displayTime(stopwatch.stop());
						}
					})
					displayTime(stopwatch.start());
				}break;
				case 'stop':{
					displayTime(stopwatch.stop());
				}break;
				case 'pause':{
					displayTime(stopwatch.pause());
				}break;
				case 'resume':{
					displayTime(stopwatch.start());
				}break;
				case 'imgCapture':{
					document.querySelector('.imgCapture>span').innerText = res.path;
				}break;
			}
		})
	})
})
</script>
</html>
